package com.pzc.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pzc.dao.ManageDao;
import com.pzc.entity.PersonManage;
import com.pzc.service.PersonManageService;


/**
 * Servlet implementation class DoAddManage
 */
@WebServlet("/DoAddManage")
public class DoAddManage extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DoAddManage() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		int id = Integer.parseInt(request.getParameter("id"));
		String nickname = request.getParameter("nickname");
		String headportraint = request.getParameter("headportraint");
		String address = request.getParameter("address");
		String gender = request.getParameter("gender");
		String birthday = request.getParameter("birthday");
		
		PersonManage pm = new PersonManage(nickname,headportraint,address,gender,birthday);
		pm.setUserid(id);
        pm.setNickname(nickname);
        pm.setBirthday(birthday);
        pm.setAddress(address);
        pm.setGender(gender);
		
		PersonManageService pms=new PersonManageService();
		
		boolean result=pms.updateProduct(pm);
		if(result){
			request.getRequestDispatcher("").forward(request, response);
		}else{
			response.sendRedirect("");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		

		
	}

}
